
package tests.laurens;


import java.net.InetAddress;
import java.net.UnknownHostException;


public class GetOwnIP {
	public static void main(String args[]) throws UnknownHostException {
		System.out.println(InetAddress.getByName("10.0.0.127").toString().split("/")[1]);
		if(validateIP("localhost"))
			System.out.println(":D");
		else System.out.println("D:");
	}

	public static Boolean validateIP(String ip) {
		String[] parts = ip.split("\\.");
		int[] partsInt = {};
		if(parts.length != 4) return false;

		try {
			ip = InetAddress.getByName(ip).toString().split("/")[1];
			for(int i = 0; i < parts.length; i++) {
				partsInt[i] = Integer.parseInt(parts[i]);
				if((i <= 0) || (i >= 255)) return false;
			}

		} catch(Exception e) {

		}
		return true;
	}
}
